﻿using BingVis.WPFClient;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using BingVis.Common;
using Moq;

namespace BingVis.WPFClient.Test
{
    
    
    /// <summary>
    ///This is a test class for StopsListViewModelTest and is intended
    ///to contain all StopsListViewModelTest Unit Tests
    ///</summary>
    [TestClass()]
    public class StopsListViewModelTest
    {
        private TestContext testContextInstance;
        private ITransitStop fakeStop1;

        public StopsListViewModelTest()
        {
            var fake = new Mock<ITransitStop>();
            fake.SetupAllProperties();
            fake.SetupGet(x => x.Id).Returns("1");
            fake.SetupGet(x => x.Name).Returns("Fake Stop");
            fakeStop1 = fake.Object;                            

        }

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        /// <summary>
        ///A test for AddStop
        ///</summary>
        [TestMethod()]
        public void Should_Add_TransitStop_If_Not_Already_In_Stops()
        {
            StopsListViewModel target = new StopsListViewModel();

            Assert.AreEqual<int>(0, target.Stops.Count);

            target.AddStop.Execute(fakeStop1);

            Assert.IsTrue(target.AddStop.CommandExecuted);
            Assert.AreEqual<int>(1, target.Stops.Count);
        }

        [TestMethod()]
        public void Should_NOT_Add_TransitStop_If_Already_In_Stops()
        {
            StopsListViewModel target = new StopsListViewModel();

            Assert.AreEqual<int>(0, target.Stops.Count);

            target.AddStop.Execute(fakeStop1);
            target.AddStop.Execute(fakeStop1);

            Assert.IsFalse(target.AddStop.CommandExecuted);
            Assert.AreEqual<int>(1, target.Stops.Count);
        }

        /// <summary>
        ///A test for StopsListViewModel Constructor
        ///</summary>
        [TestMethod()]
        public void Should_Initialize_Members()
        {
            StopsListViewModel target = new StopsListViewModel();

            Assert.IsNotNull(target.Stops);
            Assert.IsNotNull(target.AddStop);
        }
    }
}
